﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VoucherOutList.aspx.cs"
    Inherits="SalesManagement.Modules.Sales.VoucherOutList" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script language="javascript" type="text/javascript">
        function DocumentReady() {
            MethodNamespace.DocumentReady({
                success: function() {
                    ;
                }
            });
        }
        /*
        Khi chọn Phiếu Nhập kho load chi tiết phiếu nhập
        */
        function SelectionChange(Selection) {
            if (Selection.selections.items.length > 0) {
                var Row = Selection.selections.items[0];
                MethodNamespace.SelectionChange(Row.data.VoucherId);
            }
        }
        /*
        Tìm kiếm
        */
        function SearchDocument() {
            MethodNamespace.SearchDocument(1, {
                success: function() {
                    Complete_Search(grVoucherList, null, null, txtVoucherNo);
                }
            });
        }
        function DeleteProcess() {
            var items = grVoucherList.selModel.selections.items[0];
            MethodNamespace.DeleteProcess(items.id, {
                success: function(resul) {
                    if (resul) {
                        var RecoIndext = grVoucherList.store.indexOfId(items.id);
                        grVoucherList.deleteSelected();
                        grVoucherList.store.commitChanges();
                        grVoucherDetail.removeAll();
                        if (grVoucherList.store.data.length == 0)
                            SearchDocument();
                        else {
                            if (RecoIndext >= grVoucherList.store.data.length)
                                RecoIndext = grVoucherList.store.data.length - 1;
                            Complete_Search(grVoucherList, RecoIndext, null, txtVoucherNo);
                        }
                        vnMessageBox('Thông báo !', 'Xóa thành công', Ext.MessageBox.OK, 'Complete_Search(grVoucherList, null, null, txtVoucherNo);', Ext.MessageBox.INFO, 1);
                    }
                }
            });
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Store runat="server" ID="storeCustomer">
        <Reader>
            <ext:JsonReader IDProperty="ObjectId">
                <Fields>
                    <ext:RecordField Name="ObjectId">
                    </ext:RecordField>
                    <ext:RecordField Name="ObjectName">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeMaturity">
        <Reader>
            <ext:JsonReader IDProperty="MaturityId">
                <Fields>
                    <ext:RecordField Name="MaturityId">
                    </ext:RecordField>
                    <ext:RecordField Name="MaturityName">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="storeEmployee" runat="server" RemoteSort="true">
    <Reader>
        <ext:JsonReader IDProperty="EmployeeId">
            <Fields>
				<ext:RecordField Name="EmployeeId" />
					<ext:RecordField Name="EmployeeName" />
            </Fields>
        </ext:JsonReader>
    </Reader>       
</ext:Store>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="RowLayout">
        <Items>
            <ext:Toolbar ID="tbMain" runat="server">
                <Items>
                    <ext:Button runat="server" ID="btnNew" Icon="PageAdd" Text="Tạo mới">
                        <ToolTips>
                            <ext:ToolTip ID="ToolTip9" runat="server" Title="Ctr+N">
                            </ext:ToolTip>
                        </ToolTips>
                        <%--    <Listeners>
                                    <Click Handler="BeforCheckNewClick();" />
                                </Listeners>--%>
                    </ext:Button>
                    <ext:ToolbarSeparator />
                    <ext:Button runat="server" ID="btnUpdate" Text="Sửa" Icon="PageEdit">
                    </ext:Button>
                    <ext:ToolbarSeparator />
                    <ext:Button runat="server" ID="btnDelete" Text="Xóa" Icon="Delete">
                        <ToolTips>
                            <ext:ToolTip ID="ToolTip8" runat="server" Title="Shift+Delete">
                            </ext:ToolTip>
                        </ToolTips>
                        <%--    <Listeners>
                                    <Click Handler="ConfigDeleteObject()" />
                                </Listeners>--%>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
            <ext:Panel ID="Panel0" runat="server" Frame="true" Height="100" Layout="ColumnLayout"
                Border="false">
                <Defaults>
                    <ext:Parameter Name="Anchor" Value="99%">
                    </ext:Parameter>
                </Defaults>
                <Items>
                    <ext:Panel ID="Panel1" runat="server" ColumnWidth="0.5" Layout="FormLayout" LabelWidth="100"
                        Border="true">
                        <Defaults>
                            <ext:Parameter Name="Anchor" Value="99%">
                            </ext:Parameter>
                        </Defaults>
                        <Items>
                            <ext:TextField runat="server" ID="txtVoucherNo" FieldLabel="Số phiếu">
                            </ext:TextField>
                            <ext:DateField ID="dfDateFrom" runat="server" FieldLabel="Từ ngày" />
                            <ext:ComboBox ID="cbMaturity" runat="server" FieldLabel="Hạn thanh toán" StoreID="stMaturity"
                                DisplayField="MaturityName" ValueField="MaturityId" />
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Panel>
            <ext:Panel ID="Panel2" runat="server" ColumnWidth="0.4" Layout="FormLayout" LabelWidth="70"
                Border="false">
                <Defaults>
                    <ext:Parameter Name="Anchor" Value="99%">
                    </ext:Parameter>
                </Defaults>
                <Items>
                    <ext:ComboBox ID="cboCustomer" runat="server" FieldLabel="Khách hàng" Editable="false"
                        StoreID="stCustomer" DisplayField="ObjectName" ValueField="ObjectId" TriggerAction="All" />
                    <ext:DateField ID="dfDateTo" runat="server" FieldLabel="Đến ngày" />
                    <%--<ext:ComboBox ID="cbBondNo" runat="server" FieldLabel="Nhân viên" Editable="false"
                        DataIndex="Title" />--%>
                </Items>
            </ext:Panel>
            <ext:Panel ID="pnlPackCenter" runat="server" Layout="VBoxLayout" ColumnWidth="0.1"
                Border="true">
                <Defaults>
                    <ext:Parameter Name="margins" Value="0 0 5 0" Mode="Value" />
                </Defaults>
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Padding="5" Align="Center" Pack="Center" />
                </LayoutConfig>
                <Items>
                    <ext:Button ID="btSearch" runat="server" Text="Tìm kiếm" Icon="Magnifier" FormBind="true"
                        Width="60" Height="30">
                        <Listeners>
                            <Click Handler="SearchDocument()" />
                        </Listeners>
                    </ext:Button>
                </Items>
            </ext:Panel>
            <ext:GridPanel ID="GridPanel1" runat="server" AutoExpandColumn="VoucherOutNo" RowHeight="1"
                ColumnLines="true" Border="false">
                <Store>
                    <ext:Store ID="storeMain" runat="server" RemoteSort="true">
                        <Reader>
                            <ext:JsonReader IDProperty="VoucherOutId">
                                <Fields>
                                    <ext:RecordField Name="VoucherOutId" />
                                    <ext:RecordField Name="VoucherOutNo" />
                                    <ext:RecordField Name="VocherInDate" />
                                    <ext:RecordField Name="BranchId" />
                                    <ext:RecordField Name="CustomerId" />
                                    <ext:RecordField Name="ContractId" />
                                    <ext:RecordField Name="QuotationId" />
                                    <ext:RecordField Name="PaymentMethodId" />
                                    <ext:RecordField Name="MaturityId" />
                                    <ext:RecordField Name="CurrencyId" />
                                    <ext:RecordField Name="CurrencyRate" />
                                    <ext:RecordField Name="Status" />
                                    <ext:RecordField Name="PrintMethod" />
                                    <ext:RecordField Name="InvoiceType" />
                                    <ext:RecordField Name="Note" />
                                    <ext:RecordField Name="Deleted" />
                                    <ext:RecordField Name="CreatedDate" />
                                    <ext:RecordField Name="CreatedBy" />
                                    <ext:RecordField Name="UpdatedDate" />
                                    <ext:RecordField Name="UpdatedBy" />
                                    <ext:RecordField Name="IsExtraPrice" />
                                    <ext:RecordField Name="OutputMethodId" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="VoucherOutNo" DataIndex="VoucherOutNo" Header="Số phiếu" />
                        <ext:Column ColumnID="VocherInDate" DataIndex="VocherInDate" Header="Ngày chứng từ" />
                        <ext:Column ColumnID="CustomerId" DataIndex="CustomerId" Header="CustomerId" />
                        <ext:Column ColumnID="QuotationId" DataIndex="QuotationId" Header="QuotationId" />
                        <ext:Column ColumnID="PaymentMethodId" DataIndex="PaymentMethodId" Header="PaymentMethodId" />
                        <ext:Column ColumnID="MaturityId" DataIndex="MaturityId" Header="MaturityId" />
                        <ext:Column ColumnID="Status" DataIndex="Status" Header="Status" />
                    </Columns>
                </ColumnModel>
                <BottomBar>
                    <ext:PagingToolbar ID="pdgrnMain" runat="server" PageSize="10">
                    </ext:PagingToolbar>
                </BottomBar>
            </ext:GridPanel>
            <ext:GridPanel ID="GridPanel2" runat="server" AutoExpandColumn="pro_name" Border="false"
                Height="170" ColumnLines="true">
                <Store>
                    <ext:Store ID="Store2" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="pro_id">
                                <Fields>
                                    <ext:RecordField Name="pro_id" />
                                    <ext:RecordField Name="pro_name" />
                                    <ext:RecordField Name="pro_unit" />
                                    <ext:RecordField Name="pro_amount" />
                                    <ext:RecordField Name="pro_value" />
                                    <ext:RecordField Name="pro_cash" />
                                    <ext:RecordField Name="pro_VAT" />
                                    <ext:RecordField Name="pro_Acounting" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel2" runat="server">
                    <Columns>
                        <ext:Column ColumnID="pro_id" DataIndex="pro_id" Header="Mã hàng" />
                        <ext:Column DataIndex="pro_name" Header="Tên hàng" />
                        <ext:Column DataIndex="pro_unit" Header="Đơn vị tính" />
                        <ext:Column DataIndex="pro_amount" Header="Số lượng" />
                        <ext:Column DataIndex="pro_value" Header="Đơn giá" />
                        <ext:Column DataIndex="pro_cash" Header="Tổng tiền" />
                        <ext:Column DataIndex="pro_VAT" Header="VAT" />
                        <ext:Column DataIndex="pro_Acounting" Header="Chiết khấu" />
                    </Columns>
                </ColumnModel>
                <LoadMask ShowMask="true" />
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
